package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${cfg.voPackage}.${entity}VO;
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import com.bbgz.dao.system.SysOperationDao;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bbgz.common.base.service.BaseServiceImpl;
import com.bbgz.common.base.Optionals;
import com.bbgz.common.toolbox.B;
import com.bbgz.common.toolbox.V;


import org.springframework.stereotype.Service;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
@DS("${cfg.className}")
public class ${table.serviceImplName} extends BaseServiceImpl<SysOperationDao, ${table.mapperName}, ${entity},${entity}VO> implements ${table.serviceName} {
    @Override
    public ${entity}VO getLastInfo(${entity} entity) {
        return B.toBean(entity,${entity}VO.class);
    }

    @Override
    public ${entity} newInstance() {
        return new ${entity}();
    }

    @Override
    public void insertValid(${entity}VO vo) {
        super.insertValid(vo);
    }

    @Override
    public void updateValid(${entity}VO vo) {
        super.insertValid(vo);
    }

    @Override
    public void deleteValid(${entity}VO vo) {
        super.deleteValid(vo);
    }

    @Override
    public QueryWrapper<${entity}> getQueryWrapper(${entity}VO vo) {
        QueryWrapper<${entity}> queryWrapper = super.getQueryWrapper(vo);
        //添加视图中自己的条件
        //..........
        //排序
        queryWrapper.orderByDesc("sort","id");
        return queryWrapper;
    }

    @Override
    protected QueryWrapper<${entity}> operationQueryWrapper(${entity}VO vo) {
        QueryWrapper<${entity}> wrapper = super.operationQueryWrapper(vo);
        Optionals.of(vo.getActType(), V::NE).ifPresent(actType->wrapper.eq("sys_operation.act_type", actType));
        //添加视图中自己的条件

        return wrapper;
    }

    @Override
    protected String[] myField() {
        //添加操作记录列表需要的自己本身的字段  不包括sys_operation 表的字段
        return new String[]{"自己的字段"};
    }
}
